#include "StdAfx.h"


CMsgBoxWnd::CMsgBoxWnd(void)
{
}

CMsgBoxWnd::CMsgBoxWnd(CD3DGUI * pGUI)
	:CD3DWnd(pGUI)
{
}

CMsgBoxWnd::~CMsgBoxWnd(void)
{
}

BOOL CMsgBoxWnd::OnMessage(CD3DWnd * pWnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_KEYDOWN:
		{
			switch(wParam)
			{
			case VK_RETURN:
				HideMsgBox();
				return true;
			}
		}
		break;
	case WM_D3DGUI_BUTTON_CLICK:
		{
			switch(wParam)
			{
			case 1001:
				HideMsgBox();
				return true;
			}
		}
		break;
	}
	return CD3DWnd::OnMessage(pWnd,msg,wParam,lParam);
	return false;
}

void CMsgBoxWnd::StartModal()
{
	m_pGUI->SetModalWnd(this);
}
void CMsgBoxWnd::StopModal()
{
	m_pGUI->SetModalWnd(NULL);
}

void CMsgBoxWnd::ShowMsgBox(LPCTSTR Msg)
{
	CD3DWnd * pWnd=GetChildWndByName("Msg");
	if(pWnd)
		pWnd->SetText(Msg);
	SetVisible(true);
	SetFocus();
	StartModal();

}
void CMsgBoxWnd::HideMsgBox()
{
	StopModal();
	SetVisible(false);
}